package com.plian.system.controller.mt.todo;

import com.plian.Tools.base.BaseController;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.model.ListResult;
import com.plian.system.model.ObjResult;
import com.plian.system.service.mt.todo.TodoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "api/todo")
public class TodoController extends BaseController {
    @Autowired
    TodoService todoService;

    @PostMapping(value = "/list")
    public ListResult list(@RequestBody PageData pd) throws Exception {
        return todoService.list(pd);
    }

    @PostMapping(value = "/save")
    public ObjResult save(@RequestBody PageData pd) {
        return todoService.save(pd);
    }

    @PostMapping(value = "/edit")
    public ObjResult edit(@RequestBody PageData pd) {
        return todoService.edit(pd);
    }

    @PostMapping(value = "/fallback")
    public ObjResult fallback(@RequestBody PageData pd) {
        return todoService.fallback(pd);
    }

    @PostMapping(value = "/findbyid")
    public ObjResult findid(@RequestBody PageData pd) {
        return todoService.findbyid(pd);
    }

    @PostMapping(value = "/forwarding")
    public ObjResult forwarding(@RequestBody PageData pd) {
        return todoService.forwarding(pd);
    }

    @PostMapping(value = "/forwardingRecord")
    public ListResult forwardingRecord(@RequestBody PageData pd) throws Exception {
        return todoService.forwardingRecord(pd);
    }

    @PostMapping(value = "/goEdit")
    public ListResult goEdit(@RequestBody PageData pd) throws Exception {
        return todoService.goEdit(pd);
    }

    @PostMapping(value = "/read")
    public ObjResult read(@RequestBody PageData pd) throws Exception {
        return todoService.read(pd);
    }

    @PostMapping(value = "/todoInfo")
    public ListResult todoInfo(@RequestBody PageData pd) throws Exception {
        return todoService.todoInfo(pd);
    }

    /**
     * 上报
     *
     * @param pd
     * @return
     */
    @PostMapping(value = "/report")
    public ObjResult report(@RequestBody PageData pd) {
        return todoService.report((List<String>) pd.get("id"));
    }

    @PostMapping(value = "/readforHight")
    public ObjResult readforHight(@RequestBody PageData pd) {
        return todoService.readforHight((List<String>) pd.get("ids"));
    }

    @PostMapping(value = "/goHightRead")
    public ObjResult goHightRead(PageData pd) {
        return todoService.goHightRead(pd);
    }
}
